package jea.machine;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.text.MaskFormatter;

public class PanelOuvertureTransverse extends JPanel
{
	private static final long serialVersionUID = 1L;
	private JPanel topPanel, centerPanel, bottomPanel;
	
	public PanelOuvertureTransverse()
	{
		topPanel = new JPanel();
		topPanel.setLayout(new FlowLayout());
		
		 JButton btnPrevious = new JButton("Previous");
		 JButton btnNext = new JButton("Next");
		 topPanel.add(btnPrevious);
		 topPanel.add(btnNext);
		
		centerPanel = new PanelGraphic();
		this.setLayout(new BorderLayout());
		
		bottomPanel = new JPanel();
		bottomPanel.setLayout(new FlowLayout());
		
		 JLabel lblFrom     = new JLabel("From SPS Position");
		 JLabel lblTo       = new JLabel("To SPS Position");
		 JFormattedTextField txtFrom = new JFormattedTextField(createNumericFormatter("#####"));
		 txtFrom.setColumns(5);
		 JFormattedTextField txtTo   = new JFormattedTextField(createNumericFormatter("#####"));
		 txtTo.setColumns(5);

		 
		 JLabel lblFromMetric     = new JLabel("OR From SPS MetricPosition");
		 JLabel lblToMetric       = new JLabel("To SPS MetricPosition");
		 JFormattedTextField txtFromMetric = new JFormattedTextField(createNumericFormatter("####.###"));
		 txtFromMetric.setColumns(8);
		 JFormattedTextField txtToMetric   = new JFormattedTextField(createNumericFormatter("####.###"));
		 txtToMetric.setColumns(8);
		 
		 JButton btnShow	= new JButton("SHOW");		 
		 
		 bottomPanel.add(lblFrom);
		  bottomPanel.add(txtFrom);
		 bottomPanel.add(lblTo);
		  bottomPanel.add(txtTo);
		 
		 bottomPanel.add(lblFromMetric);
		  bottomPanel.add(txtFromMetric);
		 bottomPanel.add(lblToMetric);
		  bottomPanel.add(txtToMetric);
		 
		 bottomPanel.add(btnShow);
		 
		this.add(topPanel, BorderLayout.NORTH);
		this.add(centerPanel, BorderLayout.CENTER);
		this.add(bottomPanel, BorderLayout.SOUTH);
	}
	
	protected MaskFormatter createNumericFormatter(String s) 
	{
	    MaskFormatter formatter = null;
	    try {  formatter = new MaskFormatter(s);  } 
	    catch (java.text.ParseException exc) 
	    {
	        System.err.println("formatter is bad: " + exc.getMessage());
	        System.exit(-1);
	    }
	    return formatter;
	}
	
	
}
